export class ResultCode<T> implements IResultCode {
  code: string;
  msg: string;
  data: T;
  getCode(): string {
    return this.code;
  }

  getMsg(): string {
    return this.msg;
  }

  getData(): any {
    return this.data;
  }

  constructor(code: string, msg: string, data: any) {
    this.code = code;
    this.msg = msg;
    this.data = data;
  }

  static SUCCESS = new ResultCode('00000', '一切OK', null);

  static USER_ERROR = new ResultCode('A0001', '用户端错误', null);
  static REPEAT_SUBMIT_ERROR = new ResultCode(
    'A0002',
    '您的请求已提交，请不要重复提交或等待片刻再尝试。',
    null,
  );
  static USER_LOGIN_ERROR = new ResultCode('A0200', '用户登录异常', null);
  static USER_NOT_EXIST = new ResultCode('A0201', '用户不存在', null);
  static USER_ACCOUNT_LOCKED = new ResultCode('A0202', '用户账户被冻结', null);
  static USER_ACCOUNT_INVALID = new ResultCode('A0203', '用户账户已作废', null);

  static USERNAME_OR_PASSWORD_ERROR = new ResultCode(
    'A0210',
    '用户名或密码错误',
    null,
  );
  static PASSWORD_ENTER_EXCEED_LIMIT = new ResultCode(
    'A0211',
    '用户输入密码次数超限',
    null,
  );
  static USER_HAS_CREATE = new ResultCode('A0212', '用户创建失败', null);

  static CLIENT_AUTHENTICATION_FAILED = new ResultCode(
    'A0212',
    '客户端认证失败',
    null,
  );

  static VERIFY_CODE_TIMEOUT = new ResultCode('A0213', '验证码已过期', null);
  static VERIFY_CODE_ERROR = new ResultCode('A0214', '验证码错误', null);

  static ROLE_HAS_EXISTS = new ResultCode(
    'A0215',
    '角色名称或编码已存在',
    null,
  );

  static ROLE_CAN_NOT_FOUND = new ResultCode('A0215', '未找到该角色信息', null);

  static TOKEN_INVALID = new ResultCode('A0230', 'token无效或已过期', null);

  static TOKEN_ACCESS_FORBIDDEN = new ResultCode(
    'A0231',
    'token已被禁止访问',
    null,
  );

  static TOKEN_HAS_LOGIN = new ResultCode('A0232', '用户已重新登陆', null);

  static AUTHORIZED_ERROR = new ResultCode('A0300', '访问权限异常', null);
  static ACCESS_UNAUTHORIZED = new ResultCode('A0301', '访问未授权', null);
  static FORBIDDEN_OPERATION = new ResultCode(
    'A0302',
    '演示环境禁止新增、修改和删除数据，请本地部署后测试',
    null,
  );

  static PARAM_ERROR = new ResultCode('A0400', '用户请求参数错误', null);
  static RESOURCE_NOT_FOUND = new ResultCode('A0401', '请求资源不存在', null);
  static PARAM_IS_NULL = new ResultCode('A0410', '请求必填参数为空', null);

  static USER_UPLOAD_FILE_ERROR = new ResultCode(
    'A0700',
    '用户上传文件异常',
    null,
  );
  static USER_UPLOAD_FILE_TYPE_NOT_MATCH = new ResultCode(
    'A0701',
    '用户上传文件类型不匹配',
    null,
  );
  static USER_UPLOAD_FILE_SIZE_EXCEEDS = new ResultCode(
    'A0702',
    '用户上传文件太大',
    null,
  );
  static USER_UPLOAD_IMAGE_SIZE_EXCEEDS = new ResultCode(
    'A0703',
    '用户上传图片太大',
    null,
  );

  static SYSTEM_EXECUTION_ERROR = new ResultCode('B0001', '系统执行出错', null);
  static SYSTEM_EXECUTION_TIMEOUT = new ResultCode(
    'B0100',
    '系统执行超时',
    null,
  );
  static SYSTEM_ORDER_PROCESSING_TIMEOUT = new ResultCode(
    'B0100',
    '系统订单处理超时',
    null,
  );

  static SYSTEM_DISASTER_RECOVERY_TRIGGER = new ResultCode(
    'B0200',
    '系统容灾功能被出发',
    null,
  );
  static FLOW_LIMITING = new ResultCode('B0210', '系统限流', null);
  static DEGRADATION = new ResultCode('B0220', '系统功能降级', null);

  static SYSTEM_RESOURCE_ERROR = new ResultCode('B0300', '系统资源异常', null);
  static SYSTEM_RESOURCE_EXHAUSTION = new ResultCode(
    'B0310',
    '系统资源耗尽',
    null,
  );
  static SYSTEM_RESOURCE_ACCESS_ERROR = new ResultCode(
    'B0320',
    '系统资源访问异常',
    null,
  );
  static SYSTEM_READ_DISK_FILE_ERROR = new ResultCode(
    'B0321',
    '系统读取磁盘文件失败',
    null,
  );

  static CALL_THIRD_PARTY_SERVICE_ERROR = new ResultCode(
    'C0001',
    '调用第三方服务出错',
    null,
  );
  static MIDDLEWARE_SERVICE_ERROR = new ResultCode(
    'C0100',
    '中间件服务出错',
    null,
  );
  static INTERFACE_NOT_EXIST = new ResultCode('C0113', '接口不存在', null);

  static MESSAGE_SERVICE_ERROR = new ResultCode('C0120', '消息服务出错', null);
  static MESSAGE_DELIVERY_ERROR = new ResultCode('C0121', '消息投递出错', null);
  static MESSAGE_CONSUMPTION_ERROR = new ResultCode(
    'C0122',
    '消息消费出错',
    null,
  );
  static MESSAGE_SUBSCRIPTION_ERROR = new ResultCode(
    'C0123',
    '消息订阅出错',
    null,
  );
  static MESSAGE_GROUP_NOT_FOUND = new ResultCode(
    'C0124',
    '消息分组未查到',
    null,
  );

  static DATABASE_ERROR = new ResultCode('C0300', '数据库服务出错', null);
  static DATABASE_TABLE_NOT_EXIST = new ResultCode('C0311', '表不存在', null);
  static DATABASE_COLUMN_NOT_EXIST = new ResultCode('C0312', '列不存在', null);
  static DATABASE_DUPLICATE_COLUMN_NAME = new ResultCode(
    'C0321',
    '多表关联中存在多个相同名称的列',
    null,
  );
  static DATABASE_DEADLOCK = new ResultCode('C0331', '数据库死锁', null);
  static DATABASE_PRIMARY_KEY_CONFLICT = new ResultCode(
    'C0341',
    '主键冲突',
    null,
  );

  static DEPT_NAME_EXIST = new ResultCode('C0401', '部门名称已存在', null);
}
